﻿@model IEnumerable<ISS.Models.Album>
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<div style="position:relative;">
@{
    int totalImage = Model.Count();
    
    int itemPerColumn = (totalImage / 3) + 1;

    int itemPlus = totalImage - (itemPerColumn * 3);
    
    int currentItem = 0;

    int currentColumn = 1;
    
    <table>
        <tr valign="top">
        
    @foreach(ISS.Models.Album album in Model)
    {
        if(currentItem == 0)
        {
            WriteLiteral("<td valign=\"top\">");
        }
        <div class="pin" >
            <a href="@Url.Action("MyAlbum", "Image", new {  ID = album.AlbumId})"> 
                <img src='@{
        if (album.Thumbnail != ""){
            Write(Url.Content("~/Resource" + album.Thumbnail));
        }
        else
        {
            Write(Url.Content("~/Content/Images/noimage.gif"));
        }
                    }' />
            </a>

            <div>
                <a class="album-name" href="@Url.Action("MyAlbum", "Image", new {  ID = album.AlbumId})">
                    @album.AlbumName
                </a>
            </div>
            <div>
                <span><img src='@Url.Content("/Content/Images/like.jpg")' /> <b>@album.Like</b></span>
                <span><img src='@Url.Content("/Content/Images/view.jpg")' /> <b>@album.ViewCount</b></span>
            </div>
        </div>
        
        currentItem++;
        if (currentItem >= itemPerColumn)
        {
            
            WriteLiteral("</td>");
            currentItem = 0;
            currentColumn++;
        }
        //Write(album.AlbumName);    
    }

        </tr>
    </table>
}
</div>
